import axios from "axios"

// 音乐标签
async function GetAllLabel(){
  var result
  await axios({
      baseURL: 'api/label/getall',
      method: 'get',
  }).then(res => {
      result=res.data

  })
  return result
}
// 喜好分析
async function Analysis2Like(){
  var result
  await axios({
      baseURL: 'api/label/like/analysis',
      method: 'get',
  }).then(res => {
      result=res.data
 
  })
  return result
}

async function GetLabelByMusicId(musicId){
  var result
  await axios({
      baseURL: 'api/label/getlabelbymusicid/'+musicId,
      method: 'get',
  }).then(res => {
      result=res.data
  
  })
  return result
}

// 根据标签id查找音乐列表
async function SelectMusicByLabelId(labelId){
  var result
  await axios({
      baseURL: 'api/music/selectbylabelid/'+labelId,
      method: 'get',
  }).then(res => {
      result=res.data

  })
  return result
}

//  上传音乐
async function UploadMusic(MusicUploadDTO){
  var result
  await axios({
      baseURL: 'api/music/uploadmusic',
      data: MusicUploadDTO,
      headers: {'Content-Type': 'application/json;charset=UTF-8' },
      method: 'post',
  }).then(res => {
      result=res.data

  })
  return result
}

// 根据音乐id获取音乐详细信息 /getallinfo
async function GetAllInfo(musicId){
  var result
  await axios({
      baseURL: 'api/music/getallinfo?musicId='+musicId,
      method: 'get',
  }).then(res => {
      result=res.data
   
  })
  return result
}

// 查找音乐
async function SelectMusic(condition){
  var result
  await axios({
      baseURL: 'api/music/selectmusic?condition='+condition,

      method: 'get',
  }).then(res => {
      result=res.data
    
  })
  return result
}

// 热门音乐
async function GetHotMusic(){
  var result
  await axios({
      baseURL: 'api/music/hotmusic',
      method: 'get',
  }).then(res => {
      result=res.data

  })
  return result
}

//    分页返回音乐列表：
async function AllMusic(pageNumber,pageSize){
  var result
  await axios({
      baseURL: 'api/music/allmusic/'+pageNumber+'/'+pageSize,
      method: 'get',
  }).then(res => {
      result=res.data
  
  })
  return result
}

//   根据 标签查找音乐列表
async function GetMusicByLabel(labelId){
  var result
  await axios({
      baseURL: 'api/music/getmusicbylabel/'+labelId,
      method: 'get',
  }).then(res => {
      result=res.data

  })
  return result
}

// //    查找用户自己上传的音乐
async function GetMyMusic(){
  var result
  await axios({
      baseURL: 'api/music/getmymusic',
      method: 'get',
  }).then(res => {
      result=res.data
 
  })
  return result
}

//    将音乐放入收藏夹
async function Put2Collect(musicId,collectId){
  var result
  await axios({
      baseURL: 'api/music/put2collect/'+musicId+'/'+collectId,
      method: 'post',
  }).then(res => {
      result=res.data
  
  })
  return result
}


// 删除我上传的音乐
async function Delete2MyMusic(musicId){
  var result
  await axios({
      baseURL: 'api/music/deletemymusic/'+musicId,
      method: 'delete',
  }).then(res => {
      result=res.data
  
  })
  return result
}

// 点赞
async function LikeMyMusic(musicId){
  var result
  await axios({
      baseURL: 'api/music/like/'+musicId,
      method: 'post',
  }).then(res => {
      result=res.data

  })
  return result
}

// 是否点赞
async function OrNotLikeusic(musicId){
  var result
  await axios({
      baseURL: 'api/music/or/not/like/'+musicId,
      method: 'get',
  }).then(res => {
      result=res.data
   
  })
  return result
}

// 查看要修改的音乐信息
async function GetMyUpdateMusic(musicId){
  var result
  await axios({
      baseURL: 'api/music/update/'+musicId,
      method: 'get',
  }).then(res => {
      result=res.data
 
  })
  return result
}
// 修改音乐信息
async function UpdateMusic(MusicUploadDTO){
  var result
  await axios({
      baseURL: 'api/music/update',
      data: MusicUploadDTO,
      headers: {'Content-Type': 'application/json;charset=UTF-8' },
      method: 'put',
  }).then(res => {
      result=res.data
 
  })
  return result
}


export default {
  name: 'MusicAPI',
  GetAllLabel,
  Analysis2Like,
  GetLabelByMusicId,
  SelectMusicByLabelId,
  UploadMusic,
  SelectMusic,
  AllMusic,
  GetMusicByLabel,
  GetMyMusic,
  Put2Collect,
  GetAllInfo,
  Delete2MyMusic,
  LikeMyMusic,
  OrNotLikeusic,
  GetHotMusic,
  GetMyUpdateMusic,
  UpdateMusic,


}
